import re

import pymysql.cursors

# 连接数据库
connect = pymysql.Connect(host='10.40.3.158',port=33306,user='root',passwd='2018@Juyou',db='uat_maintain_copy',charset='utf8')

# 获取游标
cursor = connect.cursor()
#打印所有数据
cursor.execute("select id, project_name, internal_code_log from mt_info_project_copy1 where internal_code_log is not null AND internal_code_log!=''")

datalist=list(cursor.fetchall())

for row in datalist :

    print(row[2])
    print('--------------------')
    print(re.sub('\\-\\|.*?\\|\\-',',',row[2]))
    print()

    # print(row[2])
    # internal_code_log = re.compile(r'[-|](.*?)[|-]', re.S)  #最小匹配
    # print(re.findall(internal_code_log, row[2]))

cursor.close()
connect.close()


